//
//  UIButton+BCWeb.swift
//  BCWebImageKit
//
//  Created by chun.chen on 2021/8/26.
//

import Foundation

extension HHWebImage where Base: UIButton {
    
    /// 加载url 图片
    /// - Parameters:
    ///   - url: url description
    ///   - state: state description
    func setImage(_ url: String?, for state: UIControl.State) {
        setImage(url, state: state)
    }
    
    /// 加载url 图片
    /// - Parameters:
    ///   - url: url description
    ///   - state: state description
    ///   - placeholder: placeholder description
    func setImage(_ url: String?, state: UIControl.State,
                  placeholder: UIImage? = UIImage.bc_image(with: .lightGray)) {
        guard let url_ = url else {
            print("url 不能为空")
            return
        }
        let imgUrl = URL.bc_url(url_)

        base.sd_setImage(with: imgUrl, for: state, placeholderImage: placeholder)
    }
}
